<?php
class AutoRateConfig_3d
{

    public $betnameArr;
    public $autorateArr;
    public $table_name = "autorate_config_3d";
    public $db;
    public $tbl;

    public function AutoRateConfig_3d( $betnameArr, $autorateArr, $gametype = 1 )
    {
        global $g_gametype_3d;
        $this->betnameArr = $betnameArr;
        $this->autorateArr = $autorateArr;
        $this->db = new DB();
        $this->table_name = "autorate_config_".$g_gametype_3d[$gametype]['en'];
    }

    public function checkIfAutoRate( $bettype_id )
    {
        return true;
    }

    public function getAutoRateAll( )
    {
        global $g_2face_3d;
        $sql = "SELECT * FROM ".$this->table_name." WHERE 1";
        $result = $this->db->query( $sql );
        $reArr = array();
        while ( $row = mysql_fetch_array( $result, MYSQL_ASSOC ) )
        {
            $tempIdx = $row['bettype_id']."_".$row['subid'];
            $reArr[$tempIdx] = $row;
        }
        if ( 0 < count( $reArr ) )
        {
            return $reArr;
        }
        foreach ( $this->betnameArr as $idx => $val )
        {
            $btypeArr = explode( "_", $idx );
            $sql = "INSERT INTO ".$this->table_name." (bettype_id,subid,typeflag) VALUES (";
            $sql .= $btypeArr[0].",".$btypeArr[1].",".( in_array( $btypeArr[0], $g_2face_3d ) ? "1" : "0" ).")";
            $this->db->query( $sql );
        }
    }

    public function updateAutoRate( $dataArr )
    {
        foreach ( $dataArr as $val )
        {
            $sql = " UPDATE ".$this->table_name." SET ";
            $sql .= " money =".$val['money'];
            $sql .= ", downrate =".$val['downrate'];
            $sql .= ", uprate =".$val['uprate'];
            $sql .= ", limitrate =".$val['limitrate'];
            $sql .= ", amount_255 =".$val['amount_255'];
            $sql .= " WHERE bettype_id=".$val['id']." AND subid=".$val['subid']." AND typeflag =".$val['typeflag'];
            $this->db->query( $sql );
        }
    }

}

?>